package linear;

/**
 * 单链表
 * @author huangkh
 * @param <E>
 */
public class SingleLinkedList<E> implements Linear {

    private int size;

    Node<E> first;

    Node<E> last;

    @Override
    public void clear() {

    }

    @Override
    public boolean isEmpty() {
        return false;
    }

    @Override
    public int size() {
        return 0;
    }

    @Override
    public void each() {

    }

    @Override
    public Object elemAt(int index) {
        return null;
    }

    @Override
    public int indexOf(Object o) {
        return 0;
    }

    @Override
    public int insertElem(Object o, int index) {
        return 0;
    }

    @Override
    public int deleteElem(int index) {
        return 0;
    }

    @Override
    public boolean add(Object o) {
        if (first==null){
            first = o;
        }else{
            first.next = o;
        }
        size = size + 1;
        return true;
    }

    /**
     * 节点
     * @param <E>
     */
    private static class Node<E> {

        E date;

        Node<E> next;

        public Node(E date, Node<E> next) {
            this.date = date;
            this.next = next;
        }
    }
}
